<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>SpringMVC  &middot; sitename</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">


<meta name="description" content="" />

<meta name="keywords" content="one, two, ">


<meta property="og:title" content="SpringMVC  &middot; sitename ">
<meta property="og:site_name" content="sitename"/>
<meta property="og:url" content="https://lvzongcheng.gitee.io/framework/springmvc/" />
<meta property="og:locale" content="en-EN">


<meta property="og:type" content="article" />
<meta property="og:description" content=""/>
<meta property="og:article:published_time" content="2017-12-14T00:00:00Z" />
<meta property="og:article:modified_time" content="2017-12-14T00:00:00Z" />

  
    
<meta property="og:article:tag" content="one">
    
<meta property="og:article:tag" content="two">
    
  

  

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Article",
    "headline": "SpringMVC",
    "author": {
      "@type": "Person",
      "name": "LvZongCheng"
    },
    "datePublished": "2017-12-14",
    "description": "",
    "wordCount":  709 
  }
</script>



<link rel="canonical" href="https://lvzongcheng.gitee.io/framework/springmvc/" />

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://lvzongcheng.gitee.io/touch-icon-144-precomposed.png">
<link href="https://lvzongcheng.gitee.io/favicon.png" rel="icon">

<meta name="generator" content="Hugo 0.60.0" />

  <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<link href='https://fonts.googleapis.com/css?family=Merriweather:300%7CRaleway%7COpen+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/highlight/default.css">

  
  
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'Your Google Analytics tracking code', 'auto');
	  ga('send', 'pageview');

	</script>

</head>
<body>
  <main id="main-wrapper" class="container main_wrapper has-sidebar">
    <header id="main-header" class="container main_header">
  <div class="container brand">
  <div class="container title h1-like">
  <a class="baselink" href="https://lvzongcheng.gitee.io">
  LvZongCheng

</a>

</div>

  
<div class="container topline">
  
  淡定 执著 进取 自律


</div>


</div>

  <nav class="container nav primary no-print">
  

<a class="homelink" href="https://lvzongcheng.gitee.io">home</a>


  
<a href="https://lvzongcheng.gitee.io/framework" title="Show list of Frameworks">Frameworks</a>

<a href="https://lvzongcheng.gitee.io/java" title="Show list of Java">Java</a>

<a href="https://lvzongcheng.gitee.io/linux" title="Show list of Linux">Linux</a>

<a href="https://lvzongcheng.gitee.io/redis" title="Show list of Redis">Redis</a>

<a href="https://lvzongcheng.gitee.io/sql" title="Show list of SQL">SQL</a>

<a href="https://lvzongcheng.gitee.io/Spring" title="Show list of Spring">Spring</a>

<a href="https://lvzongcheng.gitee.io/tools" title="Show list of Tools">Tools</a>

<a href="https://lvzongcheng.gitee.io/webpage" title="Show list of WebPage">WebPage</a>

<a href="https://lvzongcheng.gitee.io/information" title="Show list of information">information</a>

<a href="https://lvzongcheng.gitee.io/network" title="Show list of network">network</a>

<a href="https://lvzongcheng.gitee.io/%E5%BE%AE%E6%9C%8D%E5%8A%A1" title="Show list of 微服务">微服务</a>

<a href="https://lvzongcheng.gitee.io/%E6%80%BB%E7%BB%93" title="Show list of 总结">总结</a>

<a href="https://lvzongcheng.gitee.io/%E6%9C%BA%E5%99%A8%E8%87%AA%E5%8A%A8%E5%8C%96" title="Show list of 机器自动化">机器自动化</a>

<a href="https://lvzongcheng.gitee.io/%E6%B1%87%E7%BC%96" title="Show list of 汇编">汇编</a>

<a href="https://lvzongcheng.gitee.io/%E8%AE%B0%E4%BA%8B%E6%9C%AC" title="Show list of 记事本">记事本</a>


</nav>

<div class="container nav secondary no-print">
  
<a id="contact-link-email" class="contact_link" rel="me" aria-label="Email" href="mailto:Lyc19880405@163.com">
  <span class="fa fa-envelope-square"></span></a>



<a id="contact-link-github" class="contact_link" rel="me" aria-label="Github" href="https://github.com/enten/hugo-boilerplate">
  <span class="fa fa-github-square"></span></a>




 


















</div>


  

</header>


<article id="main-content" class="container main_content single">
  <header class="container hat">
  <h1>SpringMVC
</h1>

</header>

  <div class="container content">
  <h6 id="heading">模型图</h6>
<p><img src="/image/StringMvc/SpringMvc%E6%A8%A1%E5%9E%8B%E5%9B%BE.png" alt="Alt text"></p>
<h6 id="heading1">时序图</h6>
<p><img src="/image/StringMvc/SpringMvc%E6%97%B6%E5%BA%8F%E5%9B%BE.png" alt="Alt text"></p>
<h6 id="heading2"></h6>
<p><img src="/image/StringMvc/SpringMvc-02.png" alt="Alt text"></p>
<h6 id="heading3">分析图</h6>
<p><img src="/image/StringMvc/SpringMvc-01.png" alt="Alt text"></p>
<h6 id="heading4">请求数据过程</h6>
<pre><code>  1. 用户向服务器发送请求，请求被Spring 前端控制Servelt DispatcherServlet捕获；
  2. DispatcherServlet对请求URL进行解析，得到请求资源标识符（URI）。
      然后根据该URI，调用HandlerMapping获得该Handler配置的所有相关
      的对象（包括Handler对象以及Handler对象对应的拦截器），最后以
      HandlerExecutionChain对象的形式返回；
  3. DispatcherServlet 根据获得的Handler，选择一个合适的HandlerAdapter。
    （附注：如果成功获得HandlerAdapter后，此时将开始执行拦截器的preHandler(...)方法）
  4.  提取Request中的模型数据，填充Handler入参，开始执行Handler（Controller)。 在填
        充Handler的入参过程中，根据你的配置，Spring将帮你做一些额外的工作：
        HttpMessageConveter： 将请求消息（如Json、xml等数据）转换成一个对象，将对象
        转换为指定的响应信息数据转换：对请求消息进行数据转换。如String转换成Integer、
        Double等数据格式化：对请求消息进行数据格式化。 如将字符串转换成格式化数字或格
        式化日期等数据验证： 验证数据的有效性（长度、格式等），验证结果存储到BindingResult或Error中
  5.  Handler执行完成后，向DispatcherServlet 返回一个ModelAndView对象；
  6.  根据返回的ModelAndView，选择一个适合的ViewResolver（必须是已经注册到Spring容器中的ViewResolver)返回给DispatcherServlet ；
  7. ViewResolver 结合Model和View，来渲染视图
  8. 将渲染结果返回给客户端。
</code></pre>
<h4 id="springmvc-">SpringMVC 配置</h4>
<ol>
<li>配置前端控制器  在web.xml中</li>
</ol>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Springmvc前端控制器   </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;servlet</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>springmvc<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#f92672">&lt;servlet-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.servlet.DispatcherServlet<span style="color:#f92672">&lt;/servlet-class&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 指定配置文件所在位置 
</span><span style="color:#75715e">  			不配置init</span><span style="color:#75715e">-</span><span style="color:#75715e">param 默认到/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/找配置文件
</span><span style="color:#75715e">  			/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/servlet的名称</span><span style="color:#75715e">-</span><span style="color:#75715e">servlet.xml
</span><span style="color:#75715e">  		</span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
  		 	<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>contextConfigLocation<span style="color:#f92672">&lt;/param-name&gt;</span>
  		 	<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>classpath:springmvc.xml<span style="color:#f92672">&lt;/param-value&gt;</span>
				<span style="color:#f92672">&lt;load-on-startup</span><span style="color:#f92672">&gt;</span>1<span style="color:#f92672">&lt;/load-on-startup&gt;</span>
  		<span style="color:#f92672">&lt;/init-param&gt;</span>
  <span style="color:#f92672">&lt;/servlet&gt;</span>
  
  <span style="color:#f92672">&lt;servlet-mapping</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>springmvc<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> *.action 
</span><span style="color:#75715e">  		   请求路径必须是.action
</span><span style="color:#75715e">  		 第一种:/*   拦截所有请求   弊端  /WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/jsp/items.jsp  报错 404找不到此请求路径 
</span><span style="color:#75715e">  		 第二种:/    拦截所有请求   弊端  .js  .css .jpg  ....   报错:样式找不到  js找不一到
</span><span style="color:#75715e">  		                       ( 配置静态资源不要进行拦截)
</span><span style="color:#75715e">  		
</span><span style="color:#75715e">  		 </span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;url-pattern</span><span style="color:#f92672">&gt;</span>*.action<span style="color:#f92672">&lt;/url-pattern&gt;</span>
  <span style="color:#f92672">&lt;/servlet-mapping&gt;</span>
	
	  <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> POS提交乱码解决 </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;filter</span><span style="color:#f92672">&gt;</span>
  	<span style="color:#f92672">&lt;filter-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/filter-name&gt;</span>
  	<span style="color:#f92672">&lt;filter-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.filter.CharacterEncodingFilter<span style="color:#f92672">&lt;/filter-class&gt;</span>
  	<span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/param-name&gt;</span>
  		<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>UTF-8<span style="color:#f92672">&lt;/param-value&gt;</span>
  	<span style="color:#f92672">&lt;/init-param&gt;</span>
  <span style="color:#f92672">&lt;/filter&gt;</span>
 	  <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 过滤器 </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;filter-mapping</span><span style="color:#f92672">&gt;</span>
  	<span style="color:#f92672">&lt;filter-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/filter-name&gt;</span>
  	<span style="color:#f92672">&lt;url-pattern</span><span style="color:#f92672">&gt;</span>*.action<span style="color:#f92672">&lt;/url-pattern&gt;</span>
  <span style="color:#f92672">&lt;/filter-mapping&gt;</span>
</code></pre></div><p>load-on-startup：表示servlet随服务启动；<br>
url-pattern：*.action的请交给DispatcherServlet处理。<br>
contextConfigLocation：指定springmvc配置的加载位置，如果不指定则默认加<br>
载WEB-INF/[DispatcherServlet 的Servlet 名字]-servlet.xml。</p>
<ol start="2">
<li>SpringMVC.xml 配置</li>
</ol>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#f92672">&lt;beans</span> <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans&#34;</span>
	<span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span> <span style="color:#a6e22e">xmlns:mvc=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/mvc&#34;</span>
	<span style="color:#a6e22e">xmlns:context=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/context&#34;</span>
	<span style="color:#a6e22e">xmlns:aop=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/aop&#34;</span> <span style="color:#a6e22e">xmlns:tx=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/tx&#34;</span>
	<span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/mvc 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/context 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/aop 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/tx 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd &#34;</span><span style="color:#f92672">&gt;</span>
		
<span style="color:#75715e">&lt;!--</span><span style="color:#75715e">================= 配置式开发开始========================== </span><span style="color:#75715e">--&gt;</span>
<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 处理器 映射器 
</span><span style="color:#75715e">	&lt;bean class=&#34;org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping&#34;/&gt;
</span><span style="color:#75715e">	</span><span style="color:#75715e">--&gt;</span>
<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.handler.SimpleUrlHandlerMapping&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 集中管理Url </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;mappings&#34;</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;props</span><span style="color:#f92672">&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e">&lt;prop key=&#34;请求路径 &#34;&gt;处理器ID&lt;/prop&gt;</span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;prop</span> <span style="color:#a6e22e">key=</span><span style="color:#e6db74">&#34;/items1.action &#34;</span><span style="color:#f92672">&gt;</span>itemsController<span style="color:#f92672">&lt;/prop&gt;</span>
				<span style="color:#f92672">&lt;prop</span> <span style="color:#a6e22e">key=</span><span style="color:#e6db74">&#34;/items2.action &#34;</span><span style="color:#f92672">&gt;</span>itemsController<span style="color:#f92672">&lt;/prop&gt;</span>
				<span style="color:#f92672">&lt;prop</span> <span style="color:#a6e22e">key=</span><span style="color:#e6db74">&#34;/items3.action &#34;</span><span style="color:#f92672">&gt;</span>items1Controller<span style="color:#f92672">&lt;/prop&gt;</span>
			<span style="color:#f92672">&lt;/props&gt;</span>
		<span style="color:#f92672">&lt;/property&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>

	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 处理器 适配器  要求处理器实现Controller接口</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/bean&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 处理器 适配器  要求处理器实现HttpRequestHandler接口</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/bean&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 视图解释器     jspViewResolver 默认支持 jstl </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.view.InternalResourceViewResolver&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置前缀 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;prefix&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;/WEB-INF/jsp/&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置后缀 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;suffix&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;.jsp&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 处理器  
</span><span style="color:#75715e">	&lt;bean name=&#34;/items1.action&#34; class=&#34;cn.itcast.core.controller.ItemsController&#34;&gt;&lt;/bean&gt;
</span><span style="color:#75715e">	</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;itemsController&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.core.controller.ItemsController&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/bean&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;items1Controller&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.core.controller.Items1Controller&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/bean&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> ===================配置式开发结束======================== </span><span style="color:#75715e">--&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> ====================注解开发 开始======================== </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置处理器映射器 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/bean&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置处理器适配器 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter&#34;</span><span style="color:#f92672">&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 视图解释器  和配置式开发一样，上面已配置这里就不用在配置</span><span style="color:#75715e">--&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置类型转换 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置日期转换 Converter </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;webBindingInitializer&#34;</span> <span style="color:#a6e22e">ref=</span><span style="color:#e6db74">&#34;customBinding&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 自定义参数绑定  spring提供</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;customBinding&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.bind.support.ConfigurableWebBindingInitializer&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 类型转换 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;conversionService&#34;</span> <span style="color:#a6e22e">ref=</span><span style="color:#e6db74">&#34;conversionService&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 参数格式  字符串类型  yyyy</span><span style="color:#75715e">-</span><span style="color:#75715e">MM</span><span style="color:#75715e">-</span><span style="color:#75715e">dd HH</span><span style="color:#75715e">-</span><span style="color:#75715e">mm</span><span style="color:#75715e">-</span><span style="color:#75715e">ss  格式化  </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;conversionService&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.format.support.FormattingConversionServiceFactoryBean&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;converters&#34;</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;list</span><span style="color:#f92672">&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 日期转换 </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.common.converter.CustomDateConverter&#34;</span><span style="color:#f92672">/&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 日期转换 </span><span style="color:#75715e">--&gt;</span>
<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 				&lt;bean class=&#34;cn.itcast.common.converter.CustomDate1Converter&#34;/&gt; </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 参数 传递 前后去掉空格 </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.common.converter.CustomTrimConverter&#34;</span><span style="color:#f92672">/&gt;</span>
			<span style="color:#f92672">&lt;/list&gt;</span>
		<span style="color:#f92672">&lt;/property&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发第二种配置文式
</span><span style="color:#75715e">	&lt;mvc:annotation</span><span style="color:#75715e">-</span><span style="color:#75715e">driven/&gt;
</span><span style="color:#75715e">	 </span><span style="color:#75715e">--&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置 处理器  本身不用配置这里   配置扫描处理器</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.itcast.core.controller&#34;</span><span style="color:#f92672">/&gt;</span>
	
	
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> ===================注解开发 结束========================= </span><span style="color:#75715e">--&gt;</span>
	
<span style="color:#f92672">&lt;/beans&gt;</span>
</code></pre></div><ol start="3">
<li>后端控制器开发</li>
</ol>
<ul>
<li>1 配置式</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">ItemsController</span> <span style="color:#66d9ef">implements</span> Controller<span style="color:#f92672">{</span>

	<span style="color:#a6e22e">@Override</span>
	<span style="color:#66d9ef">public</span> ModelAndView <span style="color:#a6e22e">handleRequest</span><span style="color:#f92672">(</span>HttpServletRequest request<span style="color:#f92672">,</span>
			HttpServletResponse response<span style="color:#f92672">)</span> <span style="color:#66d9ef">throws</span> Exception <span style="color:#f92672">{</span>
		
		System<span style="color:#f92672">.</span><span style="color:#a6e22e">out</span><span style="color:#f92672">.</span><span style="color:#a6e22e">println</span><span style="color:#f92672">(</span>1<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//商品列表
</span><span style="color:#75715e"></span>		List<span style="color:#f92672">&lt;</span>Items<span style="color:#f92672">&gt;</span> itemsList <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> ArrayList<span style="color:#f92672">&lt;</span>Items<span style="color:#f92672">&gt;</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		Items items_1 <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> Items<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_1<span style="color:#f92672">.</span><span style="color:#a6e22e">setName</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;联想笔记本&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_1<span style="color:#f92672">.</span><span style="color:#a6e22e">setPrice</span><span style="color:#f92672">(</span>6000f<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_1<span style="color:#f92672">.</span><span style="color:#a6e22e">setDetail</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;ThinkPad T430 联想笔记本电脑！&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		Items items_2 <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> Items<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_2<span style="color:#f92672">.</span><span style="color:#a6e22e">setName</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;苹果手机&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_2<span style="color:#f92672">.</span><span style="color:#a6e22e">setPrice</span><span style="color:#f92672">(</span>5000f<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_2<span style="color:#f92672">.</span><span style="color:#a6e22e">setDetail</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;iphone6苹果手机！&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		itemsList<span style="color:#f92672">.</span><span style="color:#a6e22e">add</span><span style="color:#f92672">(</span>items_1<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		itemsList<span style="color:#f92672">.</span><span style="color:#a6e22e">add</span><span style="color:#f92672">(</span>items_2<span style="color:#f92672">)</span><span style="color:#f92672">;</span>

		ModelAndView modelAndView <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> ModelAndView<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//带数据 request.setAttribute
</span><span style="color:#75715e"></span>		modelAndView<span style="color:#f92672">.</span><span style="color:#a6e22e">addObject</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;itemsList&#34;</span><span style="color:#f92672">,</span> itemsList<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//返回视图
</span><span style="color:#75715e"></span>		modelAndView<span style="color:#f92672">.</span><span style="color:#a6e22e">setViewName</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;itemsList&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		<span style="color:#66d9ef">return</span> modelAndView<span style="color:#f92672">;</span>
	<span style="color:#f92672">}</span>
</code></pre></div><ul>
<li>2 配置式</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">Items1Controller</span> <span style="color:#66d9ef">implements</span> HttpRequestHandler<span style="color:#f92672">{</span>

	<span style="color:#a6e22e">@Override</span>
	<span style="color:#66d9ef">public</span> <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">handleRequest</span><span style="color:#f92672">(</span>HttpServletRequest request<span style="color:#f92672">,</span> HttpServletResponse response<span style="color:#f92672">)</span>
			<span style="color:#66d9ef">throws</span> ServletException<span style="color:#f92672">,</span> IOException <span style="color:#f92672">{</span>
		<span style="color:#75715e">// TODO Auto-generated method stub
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//商品列表
</span><span style="color:#75715e"></span>		List<span style="color:#f92672">&lt;</span>Items<span style="color:#f92672">&gt;</span> itemsList <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> ArrayList<span style="color:#f92672">&lt;</span>Items<span style="color:#f92672">&gt;</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		Items items_1 <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> Items<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_1<span style="color:#f92672">.</span><span style="color:#a6e22e">setName</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;联想笔记本&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_1<span style="color:#f92672">.</span><span style="color:#a6e22e">setPrice</span><span style="color:#f92672">(</span>6000f<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_1<span style="color:#f92672">.</span><span style="color:#a6e22e">setDetail</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;ThinkPad T430 联想笔记本电脑！&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		Items items_2 <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> Items<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_2<span style="color:#f92672">.</span><span style="color:#a6e22e">setName</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;苹果手机&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_2<span style="color:#f92672">.</span><span style="color:#a6e22e">setPrice</span><span style="color:#f92672">(</span>5000f<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		items_2<span style="color:#f92672">.</span><span style="color:#a6e22e">setDetail</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;iphone6苹果手机！&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		itemsList<span style="color:#f92672">.</span><span style="color:#a6e22e">add</span><span style="color:#f92672">(</span>items_1<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		itemsList<span style="color:#f92672">.</span><span style="color:#a6e22e">add</span><span style="color:#f92672">(</span>items_2<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		request<span style="color:#f92672">.</span><span style="color:#a6e22e">setAttribute</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;itemsList&#34;</span><span style="color:#f92672">,</span> itemsList<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		request<span style="color:#f92672">.</span><span style="color:#a6e22e">getRequestDispatcher</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/WEB-INF/jsp/itemsList.jsp&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">.</span><span style="color:#a6e22e">forward</span><span style="color:#f92672">(</span>request<span style="color:#f92672">,</span> response<span style="color:#f92672">)</span><span style="color:#f92672">;</span>

	<span style="color:#f92672">}</span>
</code></pre></div><ul>
<li>2 注解</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#a6e22e">@Controller</span>
<span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span>value <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/item&#34;</span><span style="color:#f92672">)</span>
<span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">Items2Controller</span><span style="color:#f92672">{</span>

	<span style="color:#a6e22e">@Autowired</span>
	<span style="color:#66d9ef">private</span> ItemsService itemsService<span style="color:#f92672">;</span>

	<span style="color:#75715e">//将视图和值放在一起
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//注解开发第一个方法
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//开发配置时:有请求路径可以多个?
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//要求下面这个方法只能Get请求  不允许POST请求
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//请求路径的窄化
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span>value <span style="color:#f92672">=</span> <span style="color:#f92672">{</span><span style="color:#e6db74">&#34;/queryItems.action&#34;</span><span style="color:#f92672">,</span><span style="color:#e6db74">&#34;/queryItems1.action&#34;</span><span style="color:#f92672">}</span><span style="color:#f92672">,</span>method <span style="color:#f92672">=</span> <span style="color:#f92672">{</span>RequestMethod<span style="color:#f92672">.</span><span style="color:#a6e22e">GET</span><span style="color:#f92672">,</span>RequestMethod<span style="color:#f92672">.</span><span style="color:#a6e22e">POST</span><span style="color:#f92672">}</span><span style="color:#f92672">)</span>
	<span style="color:#66d9ef">public</span> ModelAndView <span style="color:#a6e22e">queryItems</span><span style="color:#f92672">(</span>Integer id<span style="color:#f92672">,</span>String name<span style="color:#f92672">)</span><span style="color:#f92672">{</span>
		<span style="color:#75715e">//商品列表
</span><span style="color:#75715e"></span>		List<span style="color:#f92672">&lt;</span>Items<span style="color:#f92672">&gt;</span> itemsList <span style="color:#f92672">=</span> itemsService<span style="color:#f92672">.</span><span style="color:#a6e22e">findItemsList</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//不用我们自己实例化了
</span><span style="color:#75715e"></span>		ModelAndView modelAndView <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> ModelAndView<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//带数据 request.setAttribute
</span><span style="color:#75715e"></span>		modelAndView<span style="color:#f92672">.</span><span style="color:#a6e22e">addObject</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;itemsList&#34;</span><span style="color:#f92672">,</span> itemsList<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//返回视图
</span><span style="color:#75715e"></span>		modelAndView<span style="color:#f92672">.</span><span style="color:#a6e22e">setViewName</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;itemsList&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		
		<span style="color:#66d9ef">return</span> modelAndView<span style="color:#f92672">;</span>
	<span style="color:#f92672">}</span>
	
	<span style="color:#75715e">//注：将视图和返回值分离，返回的String是视图，返回值放入Model中
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//点击修改按钮  带商品ID 中转修改页面  并且将查询的商品信息 回显在页面上  
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//Springmvc默认提供  HttpServletRequest HttpServletResponse HttpSession  Model
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//@RequestParam 获取请求中的参数,要求有参数名
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//pageNo == 1
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span>value <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/editItem.action&#34;</span><span style="color:#f92672">)</span>
	<span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">editItems</span><span style="color:#f92672">(</span>Integer id<span style="color:#f92672">,</span> Boolean flag<span style="color:#f92672">,</span>
			Model model<span style="color:#f92672">,</span>HttpServletRequest request<span style="color:#f92672">,</span>HttpServletResponse response<span style="color:#f92672">,</span>HttpSession session<span style="color:#f92672">)</span><span style="color:#f92672">{</span>
		
		
		System<span style="color:#f92672">.</span><span style="color:#a6e22e">out</span><span style="color:#f92672">.</span><span style="color:#a6e22e">println</span><span style="color:#f92672">(</span>flag<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		<span style="color:#75715e">//通过商品ID的查询商品信息
</span><span style="color:#75715e"></span>		Items item <span style="color:#f92672">=</span> itemsService<span style="color:#f92672">.</span><span style="color:#a6e22e">findItemsById</span><span style="color:#f92672">(</span>id<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		<span style="color:#75715e">//回显数据 (三种)  第一种
</span><span style="color:#75715e"></span>		model<span style="color:#f92672">.</span><span style="color:#a6e22e">addAttribute</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;item&#34;</span><span style="color:#f92672">,</span> item<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//数据无法回显到页面上     更加分离开发 
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//model
</span><span style="color:#75715e"></span>		
		<span style="color:#75715e">//跳转视图
</span><span style="color:#75715e"></span>		<span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;editItem&#34;</span><span style="color:#f92672">;</span>
	<span style="color:#f92672">}</span>
	
	
<span style="color:#75715e">//POJO传递参数
</span><span style="color:#75715e"></span><span style="color:#75715e">//	//商品信息的提交
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//包装类是绑定参数
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//redirect  怎么带参数到另外一个方法  并且要求参数必须是中文也要传过去
</span><span style="color:#75715e"></span>	<span style="color:#75715e">//forward 内部转发   带参数到另外一个方法
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span>value <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/editItemSubmit.action&#34;</span><span style="color:#f92672">)</span>
	<span style="color:#66d9ef">public</span> String  <span style="color:#a6e22e">editItemSubmit</span><span style="color:#f92672">(</span><span style="color:#a6e22e">@ModelAttribute</span><span style="color:#f92672">(</span>value <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;item&#34;</span><span style="color:#f92672">)</span> Items item<span style="color:#f92672">,</span>Model model<span style="color:#f92672">)</span><span style="color:#f92672">{</span>
		
		<span style="color:#75715e">//修改商品信息
</span><span style="color:#75715e"></span>		
		<span style="color:#75715e">//重定向传递ID
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//第一种回显
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//model.addAttribute(&#34;item&#34;, item);
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//跳转视图
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//内部转发
</span><span style="color:#75715e"></span>		<span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;editItem&#34;</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//重定向（登陆使用重定向，如果内部转发会导致不能过滤）
</span><span style="color:#75715e"></span>		<span style="color:#75715e">//return &#34;redirect:/item/queryItems.action&#34;;
</span><span style="color:#75715e"></span>	<span style="color:#f92672">}</span>
	
	<span style="color:#75715e">//返回值
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">@ModelAttribute</span>
	<span style="color:#66d9ef">public</span> Map<span style="color:#f92672">&lt;</span>String<span style="color:#f92672">,</span>String<span style="color:#f92672">&gt;</span> <span style="color:#a6e22e">queryIt</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">{</span>
		Map<span style="color:#f92672">&lt;</span>String<span style="color:#f92672">,</span>String<span style="color:#f92672">&gt;</span> map <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> HashMap<span style="color:#f92672">&lt;</span>String<span style="color:#f92672">,</span>String<span style="color:#f92672">&gt;</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		map<span style="color:#f92672">.</span><span style="color:#a6e22e">put</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;001&#34;</span><span style="color:#f92672">,</span> <span style="color:#e6db74">&#34;数码相机&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		map<span style="color:#f92672">.</span><span style="color:#a6e22e">put</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;002&#34;</span><span style="color:#f92672">,</span> <span style="color:#e6db74">&#34;数码电脑&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		<span style="color:#66d9ef">return</span> map<span style="color:#f92672">;</span>
	<span style="color:#f92672">}</span>
	
	<span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span>value <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/editItem1.action&#34;</span><span style="color:#f92672">)</span>
	<span style="color:#66d9ef">public</span> <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">editItems1</span><span style="color:#f92672">(</span>Integer id<span style="color:#f92672">,</span> Model model<span style="color:#f92672">,</span>HttpServletRequest request<span style="color:#f92672">,</span>HttpServletResponse response<span style="color:#f92672">,</span>HttpSession session<span style="color:#f92672">)</span><span style="color:#f92672">{</span>
		
		<span style="color:#75715e">//异步:ajax 请求采用返回值为void的方式
</span><span style="color:#75715e"></span>		
		<span style="color:#75715e">//通过商品ID的查询商品信息
</span><span style="color:#75715e"></span>		Items item <span style="color:#f92672">=</span> itemsService<span style="color:#f92672">.</span><span style="color:#a6e22e">findItemsById</span><span style="color:#f92672">(</span>id<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#75715e">//商品名称显示在页面上
</span><span style="color:#75715e"></span>		String name <span style="color:#f92672">=</span> item<span style="color:#f92672">.</span><span style="color:#a6e22e">getName</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		
		response<span style="color:#f92672">.</span><span style="color:#a6e22e">setContentType</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;application/json;charset=UTF-8&#34;</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#66d9ef">try</span> <span style="color:#f92672">{</span>
			response<span style="color:#f92672">.</span><span style="color:#a6e22e">getWriter</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">.</span><span style="color:#a6e22e">write</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;JSON串:&#34;</span> <span style="color:#f92672">+</span> name<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#f92672">}</span> <span style="color:#66d9ef">catch</span> <span style="color:#f92672">(</span>IOException e<span style="color:#f92672">)</span> <span style="color:#f92672">{</span>
			<span style="color:#75715e">// TODO Auto-generated catch block
</span><span style="color:#75715e"></span>			e<span style="color:#f92672">.</span><span style="color:#a6e22e">printStackTrace</span><span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		<span style="color:#f92672">}</span>
		
	<span style="color:#f92672">}</span>
<span style="color:#f92672">}</span>
</code></pre></div><ol start="4">
<li>视图开发</li>
</ol>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-javascript" data-lang="javascript"><span style="color:#f92672">&lt;</span><span style="color:#f92672">%</span><span style="color:#960050;background-color:#1e0010">@</span> <span style="color:#a6e22e">page</span> <span style="color:#a6e22e">language</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;java&#34;</span> <span style="color:#a6e22e">contentType</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;text/html; charset=UTF-8&#34;</span>
    <span style="color:#a6e22e">pageEncoding</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span><span style="color:#f92672">%</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#f92672">%</span><span style="color:#960050;background-color:#1e0010">@</span> <span style="color:#a6e22e">taglib</span> <span style="color:#a6e22e">uri</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://java.sun.com/jsp/jstl/core&#34;</span> <span style="color:#a6e22e">prefix</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;c&#34;</span> <span style="color:#f92672">%</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#f92672">%</span><span style="color:#960050;background-color:#1e0010">@</span> <span style="color:#a6e22e">taglib</span> <span style="color:#a6e22e">uri</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://java.sun.com/jsp/jstl/fmt&#34;</span>  <span style="color:#a6e22e">prefix</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;fmt&#34;</span><span style="color:#f92672">%</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#f92672">!</span><span style="color:#a6e22e">DOCTYPE</span> <span style="color:#a6e22e">html</span> <span style="color:#a6e22e">PUBLIC</span> <span style="color:#e6db74">&#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;</span> <span style="color:#e6db74">&#34;http://www.w3.org/TR/html4/loose.dtd&#34;</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">html</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">head</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">meta</span> <span style="color:#a6e22e">http</span><span style="color:#f92672">-</span><span style="color:#a6e22e">equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;Content-Type&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;text/html; charset=UTF-8&#34;</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">title</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">查询商品列表</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">i</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">l</span><span style="color:#960050;background-color:#1e0010">e</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">h</span><span style="color:#960050;background-color:#1e0010">e</span><span style="color:#960050;background-color:#1e0010">a</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">body</span><span style="color:#f92672">&gt;</span> 
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">form</span> <span style="color:#a6e22e">action</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;${pageContext.request.contextPath }/item/queryItem.action&#34;</span> <span style="color:#a6e22e">method</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;post&#34;</span><span style="color:#f92672">&gt;</span>
<span style="color:#a6e22e">查询条件</span><span style="color:#960050;background-color:#1e0010">：</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">table</span> <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;100%&#34;</span> <span style="color:#a6e22e">border</span><span style="color:#f92672">=</span><span style="color:#ae81ff">1</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">tr</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;</span><span style="color:#a6e22e">input</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;submit&#34;</span> <span style="color:#a6e22e">value</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;查询&#34;</span><span style="color:#f92672">/</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">r</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">a</span><span style="color:#960050;background-color:#1e0010">b</span><span style="color:#960050;background-color:#1e0010">l</span><span style="color:#960050;background-color:#1e0010">e</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#a6e22e">商品列表</span><span style="color:#960050;background-color:#1e0010">：</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">table</span> <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;100%&#34;</span> <span style="color:#a6e22e">border</span><span style="color:#f92672">=</span><span style="color:#ae81ff">1</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">tr</span><span style="color:#f92672">&gt;</span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">商品名称</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">商品价格</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">生产日期</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">商品描述</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">操作</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">r</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">c</span><span style="color:#f92672">:</span><span style="color:#a6e22e">forEach</span> <span style="color:#a6e22e">items</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;${itemsList }&#34;</span> <span style="color:#66d9ef">var</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;item&#34;</span><span style="color:#f92672">&gt;</span>
<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">tr</span><span style="color:#f92672">&gt;</span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">$</span>{<span style="color:#a6e22e">item</span>.<span style="color:#a6e22e">name</span> }<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">$</span>{<span style="color:#a6e22e">item</span>.<span style="color:#a6e22e">price</span> }<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;</span><span style="color:#a6e22e">fmt</span><span style="color:#f92672">:</span><span style="color:#a6e22e">formatDate</span> <span style="color:#a6e22e">value</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;${item.createtime}&#34;</span> <span style="color:#a6e22e">pattern</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;yyyy-MM-dd HH-mm-ss&#34;</span><span style="color:#f92672">/</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">$</span>{<span style="color:#a6e22e">item</span>.<span style="color:#a6e22e">detail</span> }<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
	
	<span style="color:#f92672">&lt;</span><span style="color:#a6e22e">td</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;</span><span style="color:#a6e22e">a</span> <span style="color:#a6e22e">href</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;${pageContext.request.contextPath }/item/editItem.action?id=${item.id}&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">修改</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">a</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>

<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">r</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">c</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#960050;background-color:#1e0010">f</span><span style="color:#960050;background-color:#1e0010">o</span><span style="color:#960050;background-color:#1e0010">r</span><span style="color:#960050;background-color:#1e0010">E</span><span style="color:#960050;background-color:#1e0010">a</span><span style="color:#960050;background-color:#1e0010">c</span><span style="color:#960050;background-color:#1e0010">h</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>

<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">a</span><span style="color:#960050;background-color:#1e0010">b</span><span style="color:#960050;background-color:#1e0010">l</span><span style="color:#960050;background-color:#1e0010">e</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">f</span><span style="color:#960050;background-color:#1e0010">o</span><span style="color:#960050;background-color:#1e0010">r</span><span style="color:#960050;background-color:#1e0010">m</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">b</span><span style="color:#960050;background-color:#1e0010">o</span><span style="color:#960050;background-color:#1e0010">d</span><span style="color:#960050;background-color:#1e0010">y</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>

<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#960050;background-color:#1e0010">h</span><span style="color:#960050;background-color:#1e0010">t</span><span style="color:#960050;background-color:#1e0010">m</span><span style="color:#960050;background-color:#1e0010">l</span><span style="color:#960050;background-color:#1e0010">&gt;</span><span style="color:#960050;background-color:#1e0010"></span>
</code></pre></div><ol start="5">
<li>DispatcherServlet
DispathcerServlet作为springmvc的中央调度器存在，DispatcherServlet创建时会默认
从DispatcherServlet.properties文件加载springmvc所用的各各组件，如果
在springmvc.xml中配置了组件则以springmvc.xml中配置的为准，DispatcherServlet的
存在降低了springmvc各各组件之间的耦合度。
<img src="/image/StringMvc/SpringMVC-03.JPG" alt="Alt text"></li>
</ol>
<p>1.1组件扫描器
使用组件扫描器省去在spring容器配置每个controller类的繁琐。使用&lt;context:component-scan自动扫描标记@controller的控制器类，配置如下：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 扫描controller注解,多个包中间使用半角逗号分隔 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.itcast.springmvc.controller.first&#34;</span><span style="color:#f92672">/&gt;</span>
</code></pre></div><p>1.2   RequestMappingHandlerMapping
注解式处理器映射器，对类中标记@ResquestMapping的方法进行映射，根据ResquestMapping
定义的url匹配ResquestMapping标记的方法，匹配成功返回HandlerMethod对象给前端控制器，
HandlerMethod对象中封装url对应的方法Method。</p>
<p>从spring3.1版本开始，废除了DefaultAnnotationHandlerMapping的使用，推荐使用RequestMappingHandlerMapping
完成注解式处理器映射。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;!--</span><span style="color:#75715e">注解映射器 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping&#34;</span><span style="color:#f92672">/&gt;</span>
</code></pre></div><p>1.3  RequestMappingHandlerAdapter
注解式处理器适配器，对标记@ResquestMapping的方法进行适配。</p>
<p>从spring3.1版本开始，废除了AnnotationMethodHandlerAdapter的使用，推荐使用RequestMappingHandlerAdapter
完成注解式处理器适配。
配置如下：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;!--</span><span style="color:#75715e">注解适配器 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter&#34;</span><span style="color:#f92672">/&gt;</span>
</code></pre></div><h6 id="-redirect">重定向 redirect</h6>
<p>重定向乱码：
重定向是get提交，get提交乱码修改Tomcat server.xml 在8080后添加 URIEncoding=&quot;UTF-8&rdquo;
如果没生效，是Exlipse复制了一份Tomcat ，在左侧Server中，相同位置添加 URIEncoding=&quot;UTF-8&rdquo;
内部转发 forward</p>
<h5 id="heading5">日期转换</h5>
<p>SpringMVC 参数类型传输错误报400
1.在配置文件 适配器中配置
2.继承converter接口</p>

</div>


  
</article>
      <footer id="main-footer" class="container main_footer">
  

  <div class="container nav foot no-print">
  
<a href="https://lvzongcheng.gitee.io/license">license</a>


  <a class="toplink" href="#">back to top</a>

</div>

  <div class="container credits">
  
<div class="container footline">
  
  code with <!-- raw HTML omitted --><!-- raw HTML omitted -->


</div>


  
<div class="container copyright">
  
  (c) 2015 yourname.


</div>


</div>

</footer>

    </main>
    
<script type="text/javascript">
  (function() {
    
    
    if (window.location.hostname == "localhost")
      return;
    var dsq = document.createElement('script'); dsq.async = true; dsq.type = 'text/javascript';
    dsq.src = '//your_disqus_shortname.disqus.com/count.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
</script>



<script src="/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>



    
  </body>
</html>

